<template>
    <div class="subtemp">
        <span><input type="button" value="-" @click="subtract"></span>
        <span><input type="text" v-model="count"></span>
        <span><input type="button" value="+" @click="add"></span>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                count:1
            }
        },
       methods:{
           add() {
               this.count ++;
               this.sendCount();
           },
           subtract() {
               this.count--;
               if(this.count<1) {
                   this.count = 1;
               }
               this.sendCount();
           },
           sendCount() {
               this.$emit("sendCount",this.count);
           }
       }
    }
</script>

<style scoped>
    .subtemp input {
        width: 40px;
        height: 30px;
    }
</style>